<?php

/**
 * This is the model class for table "{{companymaster}}".
 *
 * The followings are the available columns in table '{{companymaster}}':
 * @property string $idcompanymaster
 * @property string $companyname
 * @property string $address1
 * @property string $address2
 * @property string $city
 * @property string $pincode
 * @property string $contact1
 * @property string $contact2
 * @property string $email
 * @property string $website
 * @property string $fax
 * @property string $vattinno
 * @property string $itno
 * @property string $username
 * @property string $password
 */
class Companymaster extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Companymaster the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{companymaster}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('companyname', 'required'),
			array('companyname, address1, address2', 'length', 'max'=>100),
			array('city, email, website, username, password', 'length', 'max'=>50),
			array('pincode', 'length', 'max'=>6),
			array('contact1, contact2, fax', 'length', 'max'=>10),
			array('vattinno, itno', 'length', 'max'=>20),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('idcompanymaster, companyname, address1, address2, city, pincode, contact1, contact2, email, website, fax, vattinno, itno, username, password', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'idcompanymaster' => 'Idcompanymaster',
			'companyname' => 'Companyname',
			'address1' => 'Address1',
			'address2' => 'Address2',
			'city' => 'City',
			'pincode' => 'Pincode',
			'contact1' => 'Contact1',
			'contact2' => 'Contact2',
			'email' => 'Email',
			'website' => 'Website',
			'fax' => 'Fax',
			'vattinno' => 'Vattinno',
			'itno' => 'Itno',
			'username' => 'Username',
			'password' => 'Password',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('idcompanymaster',$this->idcompanymaster,true);
		$criteria->compare('companyname',$this->companyname,true);
		$criteria->compare('address1',$this->address1,true);
		$criteria->compare('address2',$this->address2,true);
		$criteria->compare('city',$this->city,true);
		$criteria->compare('pincode',$this->pincode,true);
		$criteria->compare('contact1',$this->contact1,true);
		$criteria->compare('contact2',$this->contact2,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('website',$this->website,true);
		$criteria->compare('fax',$this->fax,true);
		$criteria->compare('vattinno',$this->vattinno,true);
		$criteria->compare('itno',$this->itno,true);
		$criteria->compare('username',$this->username,true);
		$criteria->compare('password',$this->password,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}